//
    
function closeMediamgr()
{
  removeModal();
  $("#mediamgr").hide();
}

function insertInCode() {
if (selectedVignette!=null)
  barre_inserer('[['+selectedVignette.attr("title")+']]',document.myForm.content);
  
}

modalRef="";
function reposModal()
{
  $('#modal_overlay').resizeTo($.windowSize());
  $('#modal_overlay').pos($.scrollOffset());
  $(modalRef).center();
}

function makeModal(ref)
{ 
    modalRef=ref;
    $(ref).before("<div id='modal_overlay'></div>"); //make modal
    $(ref).show();
    reposModal();
}

function removeModal()
{
  modalRef="";
  $("#modal_overlay").remove();
}

function onResize()
{
        size=$.windowSize();
        $("#textarea1").height(size.h-170+"px");
        $("#textarea1").width(size.w-22+"px");
        if (modalRef!="") reposModal();            
}
       
$(document).ready(function() {
   
   $('#btMediamgr').click( function(){ 
                    frames['mediamgriframe'].location.href=_baseUrl+"&do=mediamgr";
                    makeModal("#mediamgr");
   });
   
   $('#btHelp').click( function(){
                   makeModal("#help");
   });
   
   $('#help .close').click( function(){
                   removeModal();
                   $("#help").hide();
   });

   $('#btCreatePage').click( function(){
           var nompage = prompt("nom de la nouvelle page");
           if (nompage != null) 
               window.location.href=_baseUrl+nompage+'&do=edit';
   });
   $('#btDeletePage').click( function(){
          if (confirm ("are you sure kid?"))
              alert("ok");
   });
   
   $(window).resize(onResize);
   onResize();
   $('#selectLangue').change(function(){ window.location.href=this.options[this.selectedIndex].value;  });
   $('#selectVersion').change(function(){ window.location.href=this.options[this.selectedIndex].value;  });
   $('#selectPage').change(function(){ window.location.href=this.options[this.selectedIndex].value;  });
   $('#deletePage').change(function(){ window.location.href=this.options[this.selectedIndex].value;  });
});
